package com.itbupt.eat.common;

/**
 * @Author BUPT-Dingchang
 * @Create 2024/4/29 17:18
 * ClassName: BaseContext
 * Description: 基于ThreadLocal封装的工具类
 */
public class BaseContext {

    private static ThreadLocal<Long> threadLocal = new ThreadLocal<>();

    // 保存当前登录用户的ID
    public static void setCurrentUserId(Long userId) {
        threadLocal.set(userId);
    }

    // 获取当前登录用户的ID
    public static Long getCurrentUserId() {
        return threadLocal.get();
    }
}
